package com.telrob.bytevm.instruct;

import java.util.List;

import com.telrob.bytevm.compile.Instruct;
import com.telrob.bytevm.compile.ReplaceCode;
import com.telrob.bytevm.utils.ToolUtils;
import com.telrob.bytevm.vm.Register;

public class DB implements Instruct{
	public boolean isPseudo(String opt) {
		return false;
	}
	@Override
	public boolean isComplie(String opt) {
		if("db".equals(opt.toLowerCase())) {
			return true;
		}
		return false;
	}
	
	@Override
	public byte[] complie(String line,String[] param,int curretIndex,List<ReplaceCode>labelReplace) {
		
		if(line.endsWith("\'")||line.endsWith("\"")) {
			line=line.substring(4, line.length()-1);
			line=line.replace("\\r", "\r");
			line=line.replace("\\n", "\n");
			return line.getBytes();
		}
		byte[]data=new byte[param.length-1];
		for(int i=1;i<param.length;i++) {
			int number=ToolUtils.parseNum(param[i]);
			data[i-1]=(byte)(number&0xFF);
		}
		return data;
	}

	public int isRun(byte opt) {
		return -1;
	}
	public void parseRun(Register R,byte opt,byte[]param) {
	}

}
